<?php
/**
 * Extension of SQLColumnDefinitionClause providing vendor-specific functionality as well as resolving clauses into string (which in this case are always vendor-specific).
 */
class MySQLColumnDefinitionClause extends SQLColumnDefinitionClause {
	/**
	 * Sets column as unsigned (int)
	 * 
	 * @return SQLColumnDefinitionClause
	 */
	public function setUnsigned() {
		$this->tblContents["IS_UNSIGNED"]=true;
		return $this;
	}
	
	/**
	 * Translates clause into string
	 * 
	 * (non-PHPdoc)
	 * @see AbstractSQLClause::toString()
	 */
	public function toString() {
		$output = "";
		$output .= $this->tblContents["NAME"];
		$output .= " " + $this->tblContents["DATA_TYPE"];
		if(isset($this->tblContents["LENGTH"]))				$output .= "("+$this->tblContents["LENGTH"]+")";
		if(isset($this->tblContents["IS_UNSIGNED"]))		$output .= " UNSIGNED";
		if(!isset($this->tblContents["IS_NULLABLE"]))		$output .= " NOT NULL";
		if(isset($this->tblContents["IS_AUTOINCREMENT"]))	$output .= " AUTO_INCREMENT";
		if(isset($this->tblContents["IS_PRIMARY"]))			$output .= " PRIMARY KEY";
		if(isset($this->tblContents["DEFAULT_VALUE"]))		$output .= " DEFAULT "+new SQLValue(map.get("DEFAULT_VALUE"));
		return $output;
	}
}